import request from "@/utils/request";

export default {
  search(resource, page, size, searchMap) {
    return request({
      method: "post",
      url: `/${resource}/search/${page}/${size}`,
      data: searchMap
    });
  },
  add(resource, newInfo) {
    return request({
      method: "post",
      url: `/${resource}`,
      data: {
        newInfo
      }
    });
  },
  getById(resource, id) {
    return request({
      method: "get",
      url: `/${resource}/${id}`
    });
  },
  update(resource, editInfo) {
    return request({
      method: "put",
      url: `/${resource}/${editInfo.id}`,
      data: {
        editInfo
      }
    });
  },
  delById(resource, id) {
    return request({
      method: "delete",
      url: `/${resource}/${id}`
    });
  }
};
